package com.example.loopyserver.controller;

import com.example.loopyserver.common.CommonController;
import com.example.loopyserver.dto.AnswerDTO;
import com.example.loopyserver.dto.QuestinDTO;
import com.example.loopyserver.exception.CommonException;
import com.example.loopyserver.server.QAService;
import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@CommonController
@RequiredArgsConstructor
@RequestMapping("/qa")
public class QAController {
    private final QAService qaService;

    @PostMapping("/question")
    public AnswerDTO question(@RequestBody @Valid QuestinDTO data) throws CommonException {
        return qaService.question(data.getText());
    }
}
